<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    </style>
</head>

<body>
    <input id="txt" type="text" value="10" />
    <input type="button" value="开始" id="btn">
</body>

</html>
<script>
    var seconds;
    btn.onclick = function () {
        seconds = parseInt(document.getElementById("txt").value);
        var myTimer = setInterval(function () {
            seconds--;
            if (seconds <= 0) {
                seconds = 0;
                window.clearInterval(myTimer);
            }
            document.getElementById("txt").value = seconds;
        }, 1000);
    }


</script>